<template>
  <div class="header">
    <div>我是header</div>
    <p>Count的值是{{ count }}</p>
    <p>价格是{{ price }}</p>
    <button @click="increment">累加count的值</button>
    <button @click="incrementN({ n: 3 })">count的值每次加n</button>
    <button @click="decrement">累减</button>
    <button @click="incrementWait">等一等在加</button>
    <button @click="incrementNWait({ n: 5 })">等一等在加n</button>
  </div>
</template>

<script>
import { mapMutations, mapState, mapActions } from "vuex";
export default {
  name: "Herder",
  mounted() {
    console.log(this);
    // /查看mapState方法返回的对象
    // console.log(mapState(["count", "price"]));
    // console.log(mapState({ count1: "count", price1: "price" }));
    // console.log(mapState(["count", "price"]).count.call(this));
    // console.log(
    //   mapMutations(["increment", "incrementN"]).incrementN.call(this, { n: 5 })
    // );
    // console.log(mapActions(["incrementWait", "incrementNWait"]));
  },
  computed: {
    ...mapState("count",["count", "price", "movieList"]),
    // count() {
    //   return this.$store.state.count;
    // },
    // price() {
    //   return this.$store.state.price;
    // },
  },
  methods: {
    ...mapMutations("count",["increment", "incrementN", "decrement"]),
    /* ...mapMutations({
      increment: "increment",
      incrementN: "incrementN",
    }), */
    /* increment() {
      //对mutation上的事件进行提交
      this.$store.commit("increment");
    },
    incrementN(n) {
      this.$store.commit("incrementN", { n });
    }, */
    ...mapActions("count",["incrementWait", "incrementNWait"]),
  },
};
</script>

<style scoped>
.header {
  margin: 30px;
  background: yellowgreen;
}
</style>